package com.lovestudying.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.lovestudying.dao.CourseDao;
import com.lovestudying.dao.TeacherDao;
import com.lovestudying.dao.Impl.CourseDaoImpl;
import com.lovestudying.dao.Impl.TeacherDaoImpl;
import com.lovestudying.entity.Course;
import com.lovestudying.entity.Teacher;
import com.lovestudying.service.TeacherService;
import com.lovestudying.util.PageInfo;

public class TeacherServiceImpl implements TeacherService {

	TeacherDao teacherdao = new TeacherDaoImpl();
	CourseDao coursedao = new CourseDaoImpl();

	@Override
	public int deleteById(String teacher_id) {
		// TODO Auto-generated method stub
		return teacherdao.deleteById(teacher_id);
	}

	@Override
	public int modifyById(Teacher teacher) {

		return teacherdao.updateById(teacher);
	}

	@Override
	public List<Teacher> getTeacherListByCondition(String teacherKey) {

		Map<String, Object> Where_Param = new HashMap<String, Object>();
		Where_Param.put("teacher.teacher_name", teacherKey);
		List<Teacher> data = teacherdao.findTeacherUniCourse(Where_Param, null, null, null).getData();
		for (Teacher teacher : data) {
			Map<String, Object> Where_Param2 = new HashMap<String, Object>();
			Where_Param2.put("course.teacher_id", teacher.getTeacher_id());
			PageInfo<Course> list = coursedao.findCourseUniTeacher(Where_Param2, null, null, null);
		
			teacher.setList(list.getData());
		}
		
		
		return data;
	}

}
